package com.hc.activityService;

import java.util.ArrayList;
import java.util.List;

import com.hc.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

public class FileAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private String[] fileData;

	private List<Integer> l;

	public FileAdapter(Context context, String[] fileData) {
		l = new ArrayList<Integer>();
		this.mInflater = LayoutInflater.from(context);
		this.fileData = fileData;
	}

	public void setL(List<Integer> l) {
		this.l = l;
	}

	public void setFileData(String[] fileData) {
		this.fileData = fileData;
	}

	@Override
	public int getCount() {
		return fileData.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	static class Holder{
		
		TextView t;
		ImageView v;
		
	}
	
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		
		Holder holder;
		if (convertView == null) {

			convertView = mInflater.inflate(R.layout.file_list_item, null);
			
			holder = new Holder();
			holder.t = (TextView) convertView.findViewById(R.id.textView1);
			holder.v = (ImageView) convertView.findViewById(R.id.checkBox1);
			convertView.setTag(holder);
			
		}else {
			holder = (Holder) convertView.getTag();
			
			
		}
	
		holder.t.setText(fileData[position]);
		
		
		
		holder.v.setVisibility(View.GONE);
		for (Integer i : l) {
			if (i == position) {

				holder.v.setVisibility(View.VISIBLE);
			}

		}
		return convertView;
	}

}
